package org.scohen.juploadr.uploadapi.flickrrest.authentication;

import java.util.SortedMap;
import java.util.TreeMap;

import org.scohen.juploadr.uploadapi.ProtocolException;
import org.scohen.juploadr.uploadapi.flickrrest.DefaultFlickrHandler;
import org.scohen.juploadr.uploadapi.flickrrest.FlickrMethod;
import org.scohen.juploadr.uploadapi.flickrrest.RestFlickrApi;

public class GetToken extends FlickrMethod {
    private String frob;
    private String token;
    private String username;
    private String nsid;
    private String fullName;
    private String permissions;

    public GetToken(String frob) {
        this.frob = frob;
    }

    public DefaultFlickrHandler getResponseHandler() {
        return new GetTokenResponseHandler(this);
    }

    public SortedMap<String, String> getParams() {
        SortedMap<String, String> map = new TreeMap<String, String>();
        map.put("method", "flickr.auth.getToken");
        map.put("api_key", RestFlickrApi.FLICKR_API_KEY);
        map.put("frob", frob);
        return map;
    }

    /**
     * @return Returns the fullName.
     */
    public String getFullName() {
        return fullName;
    }

    /**
     * @param fullName
     *            The fullName to set.
     */
    public void setFullName(String fullName) {
        this.fullName = fullName;
    }

    /**
     * @return Returns the nsid.
     */
    public String getNsid() {
        return nsid;
    }

    /**
     * @param nsid
     *            The nsid to set.
     */
    public void setNsid(String nsid) {
        this.nsid = nsid;
    }

    /**
     * @return Returns the token.
     */
    public String getToken() {
        return token;
    }

    /**
     * @param token
     *            The token to set.
     */
    public void setToken(String token) {
        this.token = token;
    }

    /**
     * @return Returns the username.
     */
    public String getUsername() {
        return username;
    }

    /**
     * @param username
     *            The username to set.
     */
    public void setUsername(String username) {
        this.username = username;
    }

    /**
     * @return Returns the permissions.
     */
    public String getPermissions() {
        return permissions;
    }

    /**
     * @param permissions
     *            The permissions to set.
     */
    public void setPermissions(String permissions) {
        this.permissions = permissions;
    }

    public boolean isAuthorized() {

        return false;
    }

    @Override
    protected ProtocolException buildProtocolException(int errorCode) {
        switch (errorCode) {
        case 108:
            return new InvalidFrobException();

        default:
            return null;

        }
    }

}
